package perl.lexical.classes;


public class Token {
	
	private TokenClassEnum tokenClass;
	private String lexem;
	private int row;
	private int col;
	private boolean declarated;
	private int nestingLevel;
	
	public Token(TokenClassEnum tokenClass, String lexem) {
		
		this.tokenClass = tokenClass;
		this.lexem = lexem;
	}
	
	public TokenClassEnum getTokenClass() {
		return tokenClass;
	}
	public void setTokenClass(TokenClassEnum tokenClass) {
		this.tokenClass = tokenClass;
	}
	public String getLexem() {
		return lexem;
	}
	public void setLexem(String lexem) {
		this.lexem = lexem;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getCol() {
		return col;
	}

	public void setCol(int col) {
		this.col = col;
	}

	public boolean isDeclarated() {
		return declarated;
	}

	public void setDeclarated(boolean declarated) {
		this.declarated = declarated;
	}
	
	public int getNestingLevel() {
		return nestingLevel;
	}

	public void setNestingLevel(int nestingLevel) {
		this.nestingLevel = nestingLevel;
	}

	@Override
	public String toString() {
		return tokenClass +"\t\t" + lexem
				+ "\t" + row + "\t" + col ;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + col;
		result = prime * result + ((lexem == null) ? 0 : lexem.hashCode());
		result = prime * result + row;
		result = prime * result
				+ ((tokenClass == null) ? 0 : tokenClass.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Token other = (Token) obj;		
		if (lexem == null) {
			if (other.lexem != null)
				return false;
		} else if (!lexem.equals(other.lexem))
			return false;
		if (tokenClass != other.tokenClass)
			return false;
		return true;
	}
	
	
	
}
